<template>
  <div>
    <form class="form-horizontal">
      <div class="form-group">
        <label for="exampleInputAccount9" class="col-sm-2 required">文章类型</label>
        <div class="col-md-6 col-sm-10">
          <input type="text" class="form-control" v-model="artTypeName" id="exampleInputAccount9" placeholder="请输入文章类型">
        </div>
      </div>
      <div class="form-group">
        <label for="exampleInputPassword4" class="col-sm-2 required">类型描述</label>
        <div class="col-md-6 col-sm-10">
        <textarea class="form-control" v-model="artTypeDesc" id="exampleInputPassword4" placeholder="请输入类型描述">
        </textarea>
        </div>
      </div>

      <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
          <router-link :to="{name:'article'}" class="btn btn-default">返回</router-link>
          <button type="button" class="btn btn-default" @click="addArticleType">确定</button>
        </div>
      </div>
    </form>
  </div>
</template>

<style>

</style>

<script>
  import adminService from '@/service/adminService';
  export default{
    data(){
      return {
        artTypeName: '',
        artTypeDesc: ''
      }
    },
    methods: {
      async  addArticleType(){
        let add = await adminService.addArticleType( { artTypeName: this.artTypeName, artTypeDesc: this.artTypeDesc } );
        if ( add.code ) {
          this.$router.push( '/article' );
        }
      }
    }
  }
</script>
